<title>字段维护</title>
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb" lay-separator=">">
        <a lay-href=""><i class="layui-icon layui-icon-locate"></i>您当前的位置：</a>
        <a><cite>任务管理</cite></a>
        <a><cite>字段维护</cite></a>
    </div>
</div>
<div class="layui-fluid roles-content">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md3 layui-col-lg3 left-side">
            <!-- 任务树 -->
            <div class="layui-card">
                <div class="layui-card-header">
                    <img src="../../../../dist/style/res/formFill/tem-task.png" class="card-header-icon"/>
                    <span class="card-header-title">表单列分类情况</span>
                </div>
                <div class="layui-card-body task-body">
                    <button type="button" class="layui-btn layui-btn-sm layui-btn-add btn-color T-addBtn" data-target="add">
                        <i class="layui-icon layui-icon-add-1" style="right: 35px;"></i>新增
                    </button>
                    <!-- <ul id="treeDemo"></ul> -->
                    <table class="layui-table"   id="filed-type" lay-filter="filed-type"></table>
                </div>
            </div>
        </div>
        <div class="layui-col-md9 layui-col-lg9 right-side">
            <!-- 查询条件 -->
            <div class="layui-card query-box">
                <div class="layui-card-body clearfix">
                    <div class="left-card-body">
                        <div class="layui-card-header">
                            <img src="../../../../dist/style/res/formFill/tem-task.png" class="card-header-icon"/>
                            <span class="card-header-title">列维护</span>
                        </div>
                        <div style="margin-top: 9px;margin-left: 10px;display: inline-block;">
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-save T-event" data-target="save">保存</button>
                        </div> 
                        <form class="layui-form roles-updateHtml-form " id="coloumMaten" action="" lay-filter="roles-updateHtml-form-group">
                             <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">列名称：</label>
                                    <div class="layui-input-inline"> 
                                        <input type="text"  name="name" autocomplete="off" placeholder="请输入列名称" class="layui-input">
                                    </div>
                                    <span class="icon-important">*</span>
                                </div> 
                                <div class="layui-inline">
                                    <label class="layui-form-label">长度：</label>
                                    <div class="layui-input-inline"> 
                                        <select name="length" class="layui-select" id="lengthData">
                                            <option></option>
                                         </select>
                                    </div>
                                    <span class="icon-important">*</span>
                                </div>  
                            </div> 
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">列类型：</label>
                                    <div class="layui-input-inline"> 
                                        <select name="datatype" lay-filter="datatype" class="layui-select" id="colomuType">
                                                <option></option>
                                        </select>
                                    </div>
                                    <span class="icon-important">*</span>
                                </div> 
                                <div class="layui-inline layui-hide  pulldownContent">
                                    <label class="layui-form-label ">下拉内容：</label>
                                    <div class="layui-input-inline"> 
                                        <textarea type="text"  name="supcontent" autocomplete="off" placeholder="请输内容" class="layui-textarea"></textarea>
                                    </div>
                                    <span class="icon-important">*</span>
                                </div> 
                            </div> 
                            <input type="text" name="comdataitemid" class="layui-hide"/>
                        </form>
                    </div>
                </div>
            </div>
            <!-- 填报表单 -->
            <div class="layui-card form-box">
                <div class="layui-card-body">
                    <div class="layui-serach-body">   
                        <img src="../../../../dist/style/res/formFill/tem-task.png" class="card-header-icon"/>
                        <span class="card-header-title">字段列表</span>
                        <div class="layui-input-box">
                            <label class="layui-form-label">列名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" id="filelistName" class="layui-input">
                            </div>
                        </div>
                        <button class="layui-btn layui-btn-normal layui-btn-sm layui-btn-enquiry T-event" data-target="enquiry">查询</button>
                    </div> 
                    <table class="layui-table" id="roles-table-simple" lay-filter="roles-table-operate"></table>
                    <div id="laypage"></div>
                    <script type="text/html" id="roles-table-operate-bar">
                        <a class="layui-icon layui-icon-edit my-table-btn my-table-btn-edit" lay-event="edit" lay-tips="修改"></a>
                        <a class="layui-icon layui-icon-delete my-table-btn-del T-event" lay-event="del" lay-tips="删除"></a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<style>
     /*重新添加的样式*/
     .my-table-btn-edit{
        color: #FD9404 !important;
        border-color: #FD9404;
    }
    .layui-icon-edit:before{
        content: "\e642";
    }
     .my-table-btn{
        font-size: 20px;
        border-width: 1px;
        border-style: solid;
        border-radius: 4px;
        margin-right: 4px;
    }
    .layui-form-item .layui-input-inline{
        width: 46%;
    }
    .layui-textarea{
        min-height: 50px;
    }
    .icon-important{
        color: red;;
    }
    .layui-table tbody tr.lineactive{
        background-color: #FDE7A3;
    }
    /*原来的*/
    .roles-content .left-side .layui-card{
        height: 835px;
        border-radius: 4px;
        padding: 0 13px 0 13px;
    }
    .layui-card-header .left-button{
        margin-left: 20px;
        width: 50px;
        background-color: #2669B1;
        text-align: center;
    }
    .layui-btn-save, .layui-btn-enquiry{
        width: 71px;
        text-align: right;
    }
    .layui-btn-save{
        background: url('../../dist/style/res/formFill/saveForm.png') no-repeat 10px center;
        background-color: #2669B1;
    }
    .layui-btn-enquiry{
        background: url('../../dist/style/res/formFill/search.png') no-repeat 10px center;
        background-color: #77AF6F;
    }
    .roles-content .layui-icon{
        right: 55px;
        top: 49%;
    }
    .roles-content .layui-card-header{
        height: 34px;
        border-bottom: 1px solid #D2D2D2;
        font-size: 14px;
        padding: 0 0 5px 0;
        line-height: 40px;
    }
    .roles-content .card-header-icon{
        width: 18px;
        height: 18px;
    }
    .roles-content .card-header-title{
        line-height: 30px;
        margin-left: 8px;
    }
    .roles-content .roles-updateHtml-form{
        /* display: flex; */
        width: 100%;
    }
    .roles-content .task-body{
        padding: 0;
        height: 780px;
        border-radius: 5px;
        margin-top: 10px;
    }
    .roles-content #treeDemo{
        padding: 0;
        height: 100%;
        overflow: auto;
        font-size: 14px;
    }
    .roles-content #treeDemo li {
        height: 32px;
        line-height: 32px;
        min-width: 200px;
        cursor: default;
        overflow: hidden;
        color: #373737;
        white-space:nowrap;
    } 
    #treeDemo li .per-num{
        width: 25px;
        max-width: 30px;
        font-weight: bold;
    }
    #treeDemo li .per-num, #treeDemo li .per-contnt{
        display: inline-block;
        height: 32px;
        line-height: 32px;
        overflow: hidden;
    }
    .roles-content #treeDemo .layui-icon{
        font-size: 16px;
        float: right;
    }
    .roles-content #treeDemo li:hover, .roles-content #treeDemo li.treeDemoLiActive{
        background-color: #DCE7F4;
    }
    .roles-content .query-box{
        height: 210px;
        margin-bottom: 0px;
        border-bottom: 1px solid #D2D2D2;
    }

    .roles-content .form-box{
        height: 624px;
        border-radius: 4px;
    }
    .roles-content .select-form-header{
        position: relative;
    }
    .roles-content .card-header-right{
        position: absolute;
        right: 0;
        top: 0;
    }
    .roles-content .layui-card .layui-tab{
        margin-top: 13px;
        z-index: 9999;
    }
    .roles-content .layui-tab-card .layui-tab-title{
        background: #fff;
    }
    .roles-content .layui-tab-card{
        border-top: none;
    }
    .roles-content .select-form-box{
        padding: 10px 10px 0 15px;
        height: 528px;
    }
    .roles-content .layui-this{
        border-top: 2px solid #008AE1;
    }
    .roles-content .btn-export, .btn-import, .btn-saveform{
        width: 96px;
        height: 30px;
        line-height: 30px;
        border: 1px solid #2669B1;
        border-radius: 4px;
        font-weight:600;
        font-size: 14px;
        padding-left: 31px;
        color: #FFFFFF;
        cursor: pointer;
    }
    .roles-content .btn-saveform{
        background: url(../../../../dist/style/res/formFill/saveForm.png) no-repeat #2669B1;
        background-position: 7px 5px;
    }
    .roles-content .roles-content .layui-tab-content{
        padding: 15px 9px 32px 9px;
    }
    .roles-content .layui-table tbody tr.bgRed{
        background: red;
    }
    .roles-content #test-table-cellEdit1{
        width: 100%;
        text-align: center;
    }
    .roles-content .addLine, .delLine{
        width: 24px;
        height: 22px;
        border: none;
        background-position: center center;
        background-repeat: no-repeat;
        margin-top: 4px;
        cursor: pointer;
    }
    .roles-content .addLine{
        background: url(../../../../dist/style/res/formFill/add.png);
        margin-right: 40px;
    }
    .roles-content .delLine{
        background: url(../../../../dist/style/res/formFill/del.png);
    }
    .roles-content .layui-table td, .layui-table th{
        text-align: center;
    }
    .roles-content .query-box .layui-card-body{
        padding: 0;
    }
    .roles-content .left-card-body{
        box-sizing: border-box;
        float: left;
        width: 100%;
        height: 200px;
        padding: 0 8px;
    }
    .roles-content .left-card-body .layui-form-label{
        box-sizing: border-box;
        width: inherit;
        padding: 10px 15px 9px 0;
        font-size: 16px;
        line-height: inherit;
        color: #373737;
    }
    .roles-content .left-card-body .layui-inline{
        /* width: 600px;
        margin-top: 20px; */
        width: 48%;
    }
    .layui-inline .special-content{
        margin: 27px;
    }
    .roles-content .special-key {
        vertical-align: top;
        display: inline-block;
    }
    .layui-inline .special-content button{
        background: #fff;
        color: #2669B1;
        font-size: 16px;
        line-height: 35px;
        height: 35px;
    }
    .roles-content .left-card-body .layui-input{
        height: 43px;
        line-height: 43px;
        /* border: 1px solid #E4E4E4; */
        border-radius: 6px;
        /* background: #F0F5F7; */
    }
    .roles-content .right-card-body{
        position: relative;
        float: right;
        width: 15.7%;
        height: 146px;
    }
    .roles-content .special-value {
        overflow: hidden;
        border: 1px solid #ccc;
        height: 38px;
        width: 400px;
        border-radius: 6px;
        border: 1px solid rgba(197,197,197,1);
        display: inline-block;
    }
    .roles-content .check-value-box {
        width: 100%;
        height: 100%;
        overflow-y: auto;
        padding: 2px 2px;
        display: flex;
        white-space: nowrap;
    }
    .roles-content .check-value-box div{
        display: flex;
    }
    .roles-content .check-value-box div p{
        text-align: center;
        width: 100%;
    }
    .layui-layer .layui-layer-title {
        height: 35px;
        line-height: 35px;
        padding: 0;
        border-bottom: none;
        background: url(/src/style/res/formFill/layer-head.png) no-repeat center center;
    }
    .formFill-icon {
        display: inline-block;
        width: 3px;
        height: 14px;
        background-color: #FFFFFF;
        vertical-align: middle;
        margin: 0 12px 0 24px;
    }
    .roles-content .unit{
        display: none;
    }
    .roles-content .layui-icon-closeDiv{
        position: fixed;
        margin-top: -36px;
        margin-left: 208px;
        width: 20px;
        height: 20px;
        cursor: pointer;
        background: url(../../../../dist/style/res/system/del.png) no-repeat center center;
    }
    /* 滚动条样式 */
    ::-webkit-scrollbar{
        width: 4px;
        height: 4px;
    }
    ::-webkit-scrollbar-thumb{
        border-radius: 5px;
        -webkit-box-shaow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        background: rgba(0,0,0,0.2);
    }
    ::-webkit-scrollbar-track {/*滚动条里面轨道*/
        border-radius: 0;
    }
    .my-table-btn-del{
        font-size: 20px;
        border: 1px solid;
        border-radius: 4px ;
        color: #FF4E32;
        border-color: #FF4E32;
    }
    .my-table-btn-del:hover{
		color: #0BAFFD;
		border-color: #0BAFFD;
	}
    #laypage{
        height: 33px;
        line-height: 33px;
        border: 1px solid #E6E6E6;
        border-top: none;
        font-size: 12px;
        padding: 5px 7px 0;
        white-space: nowrap;
    }
    #laypage .layui-laypage{
        margin: 0;
        position: relative;
    }
    .layui-input-box{
        display: inline-block;
    }
    .layui-serach-body .layui-input-block{
        width: 250px;
    }
    .layui-serach-body .layui-input{
        border: 1px solid #C5C5C5;
        border-radius: 6px;
    }
    #laypage .layui-laypage a, #laypage .layui-laypage .layui-laypage-spr{
        border: none;
    }
    .layui-table-view .no-data-tips{
        margin-top: 50px;
    }
   
   
</style>
<!-- 左侧列表类型 -->
<script type="text/html" id="type-table-operate-bar">
    <a class="layui-icon layui-icon-edit my-table-btn my-table-btn-edit" lay-event="edit" lay-tips="修改"></a>
    <a class="layui-icon layui-icon-delete my-table-btn-del T-event" lay-event="del" lay-tips="删除"></a>
</script>

<script type="text/html" id="permanentselectuserTpl">
    {{#
        layui.each(d, function(index,item) {
    }}
        <div class="unit-content">
            <p data-certCode="{{item.cert_code}}" data-userId="{{item.user_code}}" data-deptName="{{item.dept_name}}" data-deptCode="{{item.dept_code}}">{{item.userName}}、</p>
        </div>
    {{#
        })
    }}
</script>
<script type="text/html" id="permanentselectunitTpl">
    {{#
        layui.each(d, function(index,item) {
    }}
        <div class="unit-content">
            <p data-certCode="{{item.cert_code}}" data-userId="{{item.user_code}}" data-userName="{{item.userName}}" data-deptCode="{{item.dept_code}}">{{item.dept_name}}、</p>
        </div>
    {{#
        })
    }}
</script>
<script>
    layui.use(['admin','table','laypage', 'laytpl','layer','element','tools','form'], function(){
        var $ = layui.$,
        admin = layui.admin,
        laytpl = layui.laytpl,
        view = layui.view,
        element = layui.element,
        layer = layui.layer,
        laypage = layui.laypage,
        tools = layui.tools,
        filenames = [],
        table = layui.table,
        form = layui.form,
        liId = null,
        selectDep = [],
        originDep = [],
        layout = ['.layui-table th', '.layui-table td', '#treeDemo'],
        clickEditFlag=false,//是否点击修改--默认未点击可以新增
        clickTypeNameId="",//左侧列表点击;  
        typeNameDataLength=0,//左侧列表数据为空
        saveClickFlag=false;//控制保存按钮点击一次

        form.render(null, 'temporary-updateHtml-form-group');
        form.render(null, 'roles-updateHtml-form-group'); 
        $.each(selectDep, function(i,e) {
            e.dept_id = e.dataid;
            originDep.push(e);
        });
        //获取右侧下拉框数据
        function getColoumType(tablename,id){ 
            admin.req({
                    url: 'myapi/DC/api/rest/web/custom/DataTypeSelect',
                    data: { 
                        tablename:tablename, 
                        access_token: layui.data('layuiAdmin').access_token
                    },
                    done: function(res){ 
                         if(res.data.retcode==0){
                             var selectDataArr=res.data.data;
                             var options="";
                            for(var i=0;i<selectDataArr.length;i++){
                                options+="<option value="+selectDataArr[i].code+">"+selectDataArr[i].text+"</option>"
                            }
                            $("#"+id).empty().append(options);    
                            form.render('select');// 再次渲染select 
                            if(id=="lengthData"){
                                var select = 'dd[lay-value=64]';// 设置value
                                $('#lengthData').siblings("div.layui-form-select").find('dl').find(select).click();// 查找点击 
                            }
                         }
                    }
                })  
        }
        
        function entry(){
            getColoumType("com_data_item_fieldtype","colomuType");//列类型下拉框数据
            getColoumType("com_data_item_fieldlength","lengthData");//长度下拉框数据
            getFiledType(); 
            //初始化右侧
            getRole(clickTypeNameId, 1, 10);
        }
        entry(); 
        //左侧列表表格
        function getFiledType(){
            table.render({
                elem: '#filed-type'
                ,height: 720
                ,url: 'myapi/DC/api/rest/web/custom/FormColumnType'
                ,type:"post"
                ,where: { 
                    model:"select",
                    access_token: layui.data('layuiAdmin').access_token
                }
                ,text: {
                    none: '<div class="no-data-tips"><img src="/src/style/res/about/empty.png"><p style="color:#DBDBDB;">暂无数据</p></div>'
                }
                ,request: {
                    limitName: 'count'
                }
                ,parseData: function(res){ 
                    return {
                        "code": res.retcode, 
                        "msg": res.retmsg, 
                        "count": res.data.totalNumber, 
                        "data": res.data.data 
                    };
                }
                ,cellMinWidth: 80  
                ,cols: [ [
                { type: 'numbers', title: '序号', width: 44 }, 
                {
                    field:'name',
                    title: '分类名称', 
                    minWidth: 200,
                    templet: function(d){
                        return '<span lay-tips="'+ d.name +'">'+ d.name +'</span>'
                    }
                }  
                ,{ field: 'opearte', title:'操作', toolbar: '#type-table-operate-bar', width: 100 }
                ]
                ]
                ,even: true 
                ,done: function(res, curr, count){   
                    typeNameDataLength=res.data.length;
                    clickTypeNameId=""; 
                    $('[lay-id="filed-type"]').find(".layui-table-body tr").eq(0).click();
                    tools.setFont(layout);
                }
            }); 
        }
    
        //点击左侧表格
        table.on('row(filed-type)', function(obj){  
                $('[lay-id="filed-type"]').find(obj.tr.selector).addClass('lineactive');
                $('[lay-id="filed-type"]').find(obj.tr.selector).siblings().removeClass('lineactive');
                clickTypeNameId=obj.data.id;
                getRole(clickTypeNameId, 1, 10);
        }); 
        //左侧表格操作栏点击
        table.on('tool(filed-type)', function(obj){
            layui.stope(obj.ev);
            var event = obj.event,
                data = obj.data,
                thisModel = null,
                memoTitle = '';  
            if(event == 'edit'){//修改
                var updateParam= {  
                                    model:"update", 
                                    id:data.id,
                                    access_token: layui.data('layuiAdmin').access_token
                                }
                addEditFun("修改分类",data.name,updateParam)
            } else if(event== 'del'){//删除
                layer.confirm('确定要删除?', {icon: 3, title:'提示'}, function(index){
                    admin.req({
                            url: 'myapi/DC/api/rest/web/custom/FormColumnType',
                            data: {
                                model:"del", 
                                id:data.id,
                                access_token: layui.data('layuiAdmin').access_token
                            },
                            done: function(res){
                                layer.msg(res.data.retmsg,{time:1000},function(){
                                    getFiledType(); 
                                }) 
                            }
                        })
                    layer.close(index);
                });
            }
        })
        //左侧新增
        $(".T-addBtn").on("click",function(){
            var insertParam= {  
                            model:"insert",  
                            access_token: layui.data('layuiAdmin').access_token
                        }
                addEditFun("新增分类","",insertParam) 
        })
        //弹出修改和新增的框
        function addEditFun(title,typeName,requestParam){
            var clickfeedbackFlag=false;
                layer.open({
                    id: 'usermemo',
                    type: 1,
                    title: '<i class="formFill-icon"></i><span style="color:#FFF;">'+title+'</span>',
                    area: ['300px', '180px'],
                    offset: 'auto',
                    shadeClose: true,
                    resize: false,
                    success: function(lay, index){
                        view(this.id).render('./system/typeOperate/addEdittype', {
                            showReview: false,
                            typeName:typeName
                        });
                    },
                    btn: ['确定', '取消'],
                    btnAlign: 'c',
                    yes: function(index, layero){
                        //修改数据
                            var typeNameValue = $('.typeName').val();
                            requestParam.name=typeNameValue;
                            if(!clickfeedbackFlag){ 
                                clickfeedbackFlag=true;
                                if(typeNameValue.trim()!=""){ 
                                        admin.req({
                                            url: 'myapi/DC/api/rest/web/custom/FormColumnType',
                                            type: 'post',
                                            data:requestParam,
                                            success: function(res){  
                                                if(res.data.retcode == '0'){ 
                                                    layer.msg(res.data.retmsg,{time:1000},function(){
                                                        layer.close(index);
                                                        clickfeedbackFlag=false;
                                                        getFiledType(); 
                                                    }) 
                                                }else{
                                                    clickfeedbackFlag=false;
                                                    layer.msg(res.data.retmsg,{time:1000})
                                                }
                                            }
                                        }) 
                                }else{
                                    clickfeedbackFlag=false;
                                    layer.msg("分类名称不能为空！",{time:1000})
                                }
                            }
                            
                    },
                    btn2: function(index, layero){}
                })
        }

    /*************************** 右侧列表维护一系列操作*************************************************/
             form.on('select(datatype)', function(data){ 
				 if(data.value=="pulldown"){
                    $(".pulldownContent").removeClass("layui-hide");
                 }else{
                    $(".pulldownContent").addClass("layui-hide");
                 }
			}); 
        //设置表单值
        function setFormData(clickTrParam,id){ 
            for(var key in clickTrParam){
                var _this=$('#'+id).find("[name='"+key+"']");
                var tagName=$('#'+id).find("[name='"+key+"']").prop("tagName");//标签名
                switch(tagName){
                    case "INPUT": 
                        $(_this).val(clickTrParam[key]); 
                        break;
                    case "SELECT": 
                        $(_this).val(clickTrParam[key]); 
                        if(key=="datatype"){
                            $(_this).siblings(".layui-unselect").find("input").val(clickTrParam.datatypename)
                            if(clickTrParam[key]=="pulldown"){ 
                                 $(".pulldownContent").removeClass("layui-hide");
                            }else{
                                $(".pulldownContent").addClass("layui-hide");
                            }
                        }else if(key=="length"){  
                                $(_this).siblings(".layui-unselect").find("input").val(clickTrParam.lengthname);
                        } 
                        break;
                    case "TEXTAREA":
                        $(_this).val(clickTrParam[key]); 
                        break;	
                }
            }
        }
        //获取表单所有数据 
        function getFormParam(id){
            var formArr=$('#'+id).serializeArray();
            var addParam={};
            for(var i=0;i<formArr.length;i++){
                var nameO=formArr[i].name; 
                addParam[formArr[i].name]=formArr[i].value; 
            }
            return addParam;
        }
        //判断表单项是否为空
        function isEmpty(strParam){
            for(var key in strParam){
                var obj=strParam[key];  
                if(typeof obj == "undefined" || obj == null || obj == ""){
                    return true;
                } 
            }
            return false;   
        }
        //保存点击
        $(".layui-btn-save").on("click",function(){ 
            if(!saveClickFlag){  
                saveClickFlag=true;
                if(!clickEditFlag){//新增
                    var formParam=getFormParam("coloumMaten");
                    delete formParam.comdataitemid; 
                    if(clickTypeNameId!=""){
                        if(formParam.datatype!="pulldown"){
                            delete formParam.supcontent; 
                        }
                        if(!isEmpty(formParam)){
                            formParam.model="insert";
                            formParam.data_item_type=clickTypeNameId; 
                            rightColumOperateFun(formParam);
                        }else{
                            saveClickFlag=false;
                            layer.msg("必填项需输入!",{time:1000})
                        }
                    }else{
                        saveClickFlag=false;
                        if(typeNameDataLength>0){
                            layer.msg("请选择字段分类!",{time:1000})
                        }else{
                            layer.msg("请先创建字段分类!",{time:1000})
                        }
                        
                    }

                }else{//修改操作
                    var formUpdateParam=getFormParam("coloumMaten"); 
                    if(formUpdateParam.datatype!="pulldown"){
                            delete formUpdateParam.supcontent; 
                    }
                    if(!isEmpty(formUpdateParam)){
                        formUpdateParam.model="update";
                        rightColumOperateFun(formUpdateParam);
                    }else{
                        layer.msg("必填项需输入!",{time:1000})
                    }
                } 
            }
        }) 
		//监听工具条
		table.on('tool(roles-table-operate)', function (obj) {
            var data = obj.data; 
			switch(obj.event) {
				case 'edit':
                clickEditFlag=true;  
                setFormData(obj.data,"coloumMaten");
                break;
                case 'del':
                    layer.confirm('确认删除？',{title: '提示'}, function (index) {
                        var delParam={
                            model:"del",
                            comdataitemid:obj.data.comdataitemid
                        }
                        rightColumOperateFun(delParam); 
                        layer.close(index)
                    });
                break;
				default:
				break;
			}
		});



        //新增，修改操作
        function rightColumOperateFun(operaParam){
            admin.req({
                url: 'myapi/DC/api/rest/web/custom/FormColumn',
                type:"post",
                data: operaParam,
                done: function(res){   
                    if(res.data.retcode==0){
                        layer.msg(res.data.retmsg,{time:1000},function(){
                            clearFormData(); 
                            getRole(clickTypeNameId, 1, 10);
                        })
                    }else{
                        saveClickFlag=false;
                        layer.msg(res.data.retmsg,{time:1000});   
                    }
                }
            })
        } 
        //查询
        $(".layui-btn-enquiry").on("click",function(){
           var searchName= $("#filelistName").val(); 
            getRole(clickTypeNameId, 1, 10,searchName);
        })
        
        //清除还原数据
        function clearFormData(){
            clickEditFlag=false;
            saveClickFlag=false;
            $(".pulldownContent").addClass("layui-hide");
            document.getElementsByTagName("form")[0].reset();
        }
        //查询字段列表
        function getRole(typeId, page, count, searchName){ 
            var paramArr = {
                model: "select", 
                page: page, 
                count: count,
                data_item_type:typeId,
                access_token: layui.data('layuiAdmin').access_token
            };
            searchName ? paramArr.name = searchName : '';
            admin.req({
                url: 'myapi/DC/api/rest/web/custom/FormColumn',
                data: paramArr,
                type:"post",
                done: function(res){
                    var data = res.data.data;
                    if(res.retcode == '0' && data){
                        clickEditFlag=false;
                        table.render({
                            elem: '#roles-table-simple',
                            height: 500,
                            text: {
                                none: '<div class="no-data-tips"><img src="/src/style/res/about/empty.png"><p style="color:#DBDBDB;">暂无数据</p></div>'
                            },
                            limit: window.limitNum, 
                            cellMinWidth: 80 
                            ,cols: [[
                                { type: 'numbers', title: '序号', width: 44 },
                                {
                                    field:'typename',
                                    title: '所属分类', 
                                    minWidth: 200,
                                    templet: function(d){
                                        return '<span lay-tips="'+ d.typename +'">'+ d.typename +'</span>'
                                    }
                                },
                                {
                                    field:'name',
                                    title: '列名称', 
                                    minWidth: 200,
                                    templet: function(d){
                                        return '<span lay-tips="'+ d.name +'">'+ d.name +'</span>'
                                    }
                                },
                                {
                                    field:'datatypename',
                                    title: '列类型', 
                                    minWidth: 200,
                                    templet: function(d){
                                        return '<span lay-tips="'+ d.datatypename +'">'+ d.datatypename +'</span>'
                                    }
                                },
                                {
                                    field:'lengthname',
                                    title: '长度', 
                                    minWidth: 50,
                                    templet: function(d){
                                        return '<span lay-tips="'+ d.lengthname +'">'+ d.lengthname +'</span>'
                                    }
                                },
                                {
                                    field:'creation_date',
                                    title: '操作时间', 
                                    minWidth: 200,
                                    templet: function(d){
                                        return '<span lay-tips="'+ d.creation_date +'">'+ d.creation_date +'</span>'
                                    }
                                },
                                {
                                    field:'created_user_name',
                                    title: '操作人', 
                                    minWidth: 200,
                                    templet: function(d){
                                        return '<span lay-tips="'+ d.created_user_name +'">'+ d.created_user_name +'</span>'
                                    }
                                },
                                { title: '操作', align: 'center', toolbar: '#roles-table-operate-bar' }
                            ]],
                            skin: 'nob',
                            even: true,
                            data: data,
                            done: function(response, curr, count){  
                                response.data && response.data.length > 0 ? reloadLaypage(res.data.totalNumber, page, count) : $('#laypage').empty(); 
                                tools.setFont(layout);
                            } 
                        })
                    } 
                }
            })
        }
        /*@method 加载分页
        *@param totalNumber 数据总数
        *@param pageNum 起始页
        *@param listNum 每页的条数
        */
        function reloadLaypage(totalNumber, pageNum, listNum){   
            laypage.render({
                elem: 'laypage',
                count: totalNumber, 
                curr: pageNum, 
                limit: listNum, 
                limit: 10,
                next:'<i class="layui-icon">&#xe602;</i>',
                prev:'<i class="layui-icon">&#xe603;</i>',
                first: '<i class="layui-icon">&#xe65a;</i>',
                last: '<i class="layui-icon">&#xe65b;</i>',
                layout: ['refresh', 'first', 'prev', 'skip', 'count', 'allPage', 'next', 'last'],
                extend:{
                    first: true, //是否显示首页
                    spr: false,//是否显示页码分页符号 默认显示
                    pagecount: true//页码是否显示总数  groups=1时才有效
                },
                jump: function(obj, first){
                    if(!first){ //首次不执行
                        getRole(clickTypeNameId, obj.curr, obj.limit);
                    }
                }
            })
        } 
        //查询绑定enter键
        $(document).keydown(function(event){
            if(event.keyCode == 13){
                $('.layui-btn-enquiry').click();
            }
        })
    })
</script>